RELEASED TO THE PUBLIC DOMAIN BY CODEWORKS DEVELOPMENT, DECEMBER 1993.
You may freely copy, distribute and reuse the code in this example. Codeworks disclaims any warranty of any kind, expressed or implied, as to its fitness for any particular use.
Info: Implementation of the DoodleBundle class. DoodleBundle is a subclass of NXBundle designed specifically for managing dynamically loaded modules containing a single Doodle object. DoodleManager creates one DoodleBundle instance for each doodle module that it finds in the Library directories. When asked for its Doodle, a DoodleBundle will dynamically load its code file, create an instance of its Doodle subclass, and then return the instance to DoodleManager. DoodleBundle also provides localized strings describing its Doodle.
Info: Provides access to the doodleName instance variable. This string names the Doodle for the user. DoodleManager uses the string to create a PopUpList of available Doodle modules. DoodleBundle does not look up doodleName until needed.
Note that we have DoodleBundle implement doodleName, rather than Doodle itself. This allows us to get the name of a module before we have actually loaded the module or instantiated the Doodle. By doing this, we can fill a UI control with the names of the options while still deferring loading and instantiating until the modules are needed.
Instead of using the local string functions, we could have just taked the doodle module's file name and stripped the extension. However, that way user interface strings would be tied to file names. Also, our method lets us substitute more descriptive names--for instance, Face can become Smiley-Face.
Info: Provides access to the doodleDescription instance variable. This string describes the Doodle for the user. DoodleManager uses the string to fill a TextField. DoodleBundle does not look up doodleDescription until needed.
The same points about doodleName apply to doodleDescription.
Info: Provides access to the doodle instance variable. Each DoodleBundle has its own Doodle instance that is created from a dynamically loaded Doodle subclass. DoodleManager lets DoodleBundle keep track of the actual Doodle. DoodleBundle will not load its code file or create its Doodle instance until it is asked. This way, DoodleManager can create the DoodleBundles when it scans the Library directories, but not load the code files or create Doodles until they are needed.